﻿using ConfExpert.Forms.Base;
using DevExpress.Utils;
using DevTeam;
using System;
using System.Drawing;

namespace ConfExpert.Forms.SatinAlma.YeniYapi
{
    public partial class UreticiKodlariMask : XForm
    {
        public UreticiKodlariMask()
        {
            InitializeComponent();
        }

        private void UreticiKodlariMask_Load(object sender, EventArgs e)
        {

            btnKaydet.ItemClick += btnKaydet_ItemClick;
            gridView2.Init("GerUreticiKodlariMask");
            gridView2.AddDetailGrid(gridView3, "VendorId");
            gridView3.AddColumn("KodUzunlugu", typeof(int), "LEN(UreticiKodu)");
            gridView3.YanYanaGetir("KodUzunlugu:KaliteId");
            gridView3.MakeColumnInvisible("VendorId");

            gridView2.FormatAsNumber(0, "Adet");
            gridView2.AddSummary("Adet");
            gridView3.AddSummary();

            gridView3.RowCellStyle += gridView3_RowCellStyle;
            gridView2.BestFitColumns();
            gridView3.BestFitColumns();
        }

        void gridView3_RowCellStyle(object sender, DevExpress.XtraGrid.Views.Grid.RowCellStyleEventArgs e)
        {
            if (e.RowHandle > -1)
                if (e.Column.FieldName == "UreticiKodu")
                    e.Appearance.Font = new Font(AppearanceObject.DefaultFont, FontStyle.Bold);
        }

        void btnKaydet_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            gridView3.EndEditing();
            gridView3.Update("UreticiKodlariId,UreticiKodu,KaliteId,KaliteAciklama", "UreticiKodlari");
            //gridView3.RefreshEditor(true);
        }
    }
}
